#include<iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#define path "./myfifo"
using namespace std;
//退出码
enum 
{
    FIFO_CREATE_ERR = 1,
    FIFO_DELETE_ERR,
    FIFO_OPEN_ERR
    
};
//初始化命名管道
class namepipe
{
public:
    namepipe()
    {
        int n=mkfifo(path,0666);
        if(n<0)
        {
           perror("mkfifo");
           exit(FIFO_CREATE_ERR);
        }
    }
    ~namepipe()
    {
        int m = unlink(path);
        if(m == -1)
        {
            perror("unlink:");
            exit(FIFO_DELETE_ERR);
        }
    }
};
